//go:build wireinject

package main

import (
	"basic-go/syntax/webook/internal/repository"
	"basic-go/syntax/webook/internal/repository/cache"
	"basic-go/syntax/webook/internal/repository/dao"
	"basic-go/syntax/webook/internal/service"
	"basic-go/syntax/webook/internal/web"
	"basic-go/syntax/webook/ioc"
	"github.com/gin-gonic/gin"
	"github.com/google/wire"
)

func InitWebServer() *gin.Engine {
	wire.Build(
		ioc.InitDB,
		ioc.InitRedis,
		//ioc.InitLocalCache,

		dao.NewGormUserDAO,

		cache.NewRedisUserCache,
		cache.NewRedisCodeCache,
		//cache.NewMemCodeCache,

		repository.NewUserRepository,
		repository.NewCacheCodeRepository,

		ioc.InitSms,
		service.NewUserService,
		service.NewcodeService,

		web.NewUserHandler,

		//ioc.CorsFunc,
		ioc.MiddlwareHandlerFunc,
		ioc.InitWeb,
	)
	return gin.Default()
}
